<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <input type="text" name="prv" />
  <input type="text" name="city" />
  <button>查询</button>
  <ul></ul>
  <body>
    <script src="./js/axios.js"></script>
    <script>
      const prv = document.querySelector('input[name=prv]')
      const city = document.querySelector('input[name=city]')
      const btn = document.querySelector('button')
      const list = document.querySelector('ul')
      btn.addEventListener('click', async function () {
        const pname = prv.value
        const cname = city.value
        const res = await axios({
          url: 'http://ajax-api.itheima.net/api/area',
          method: 'GET',
          params: { pname, cname },
        })
        const {
          data: { data },
        } = res

        list.innerHTML = data
          .map((item) => {
            return `<li>${item}</li>`
          })
          .join('')
      })
    </script>
  </body>
</html>
